Page({
  data:{
    user:{},
    
    array: ['业务中心', '浙江奇兵', '阜阳大可', '江苏新沂', '苔花家居'],
    index: 0
  },
  onLoad(query) {
    // 页面加载
    this.setData({user: getApp().globalData.user})
    switch (this.data.user.CompanyId) {
      case 0: this.setData({index:0})
        break;
      case 1: this.setData({index:1})
        break;
      case 5: this.setData({index:2})
        break;
      case 6: this.setData({index:3})
        break;
      case 7: this.setData({index:4})
        break;
      default:
        break;
    }
  },
  onReady() {
    // 页面加载完成
  },
  onShow() {
    // 页面显示
  },
  toLogin() {
    getApp().globalData.Authorization = ""
    dd.navigateTo({
      url:"/pages/login/login?code=401"
    })
  },
  bindPickerChange(e) {
    this.setData({
      index: e.detail.value,
    });
    var CompanyId = null
    switch (e.detail.value) {
      case 0: CompanyId = 0
        break;
      case 1: CompanyId = 1
        break;
      case 2: CompanyId = 5
        break;
      case 3: CompanyId = 6
        break;
      case 4: CompanyId = 7
        break;
      default: CompanyId = 0
        break;
    }
    getApp().req({
      url: "/auth/changecompany/"+CompanyId,
      type: "post",
      cb(res){
        getApp().globalData.user = res.data.user
      }
    })
  },
  changeCompany() {

  },
  test(){
    console.log(getApp().globalData)
    getApp().globalData.Authorization = ''
     dd.navigateTo({
      url:"/pages/login/login"
    })
  },
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
});
